package com.penglecode.netty.pool;

import org.apache.commons.pool.BasePoolableObjectFactory;

import com.penglecode.netty.client.NettyClient;

public class PoolableNettyClientFactory extends BasePoolableObjectFactory<NettyClient> {

	private String serverHost;
	
	private int port;
	
	public PoolableNettyClientFactory(String serverHost, int port) {
		super();
		this.serverHost = serverHost;
		this.port = port;
	}

	public void destroyObject(NettyClient obj) throws Exception {
		if(obj != null){
			obj.close();
		}
	}

	public boolean validateObject(NettyClient obj) {
		return super.validateObject(obj);
	}

	public NettyClient makeObject() throws Exception {
		return new NettyClient(serverHost, port, "123456");
	}

	
}
